package com.shortlink.admin.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.shortlink.admin.dao.entity.ShortLinkDO;
import com.shortlink.admin.dto.req.shortlink.ShortLinkBatchCreateReqDTO;
import com.shortlink.admin.dto.req.shortlink.ShortLinkCreateReqDTO;
import com.shortlink.admin.dto.req.shortlink.ShortLinkGroupPageReqDTO;
import com.shortlink.admin.dto.req.shortlink.ShortLinkUpdateReqDTO;
import com.shortlink.admin.dto.resp.shortlink.ShortLinkVO;
import com.shortlink.admin.remote.dto.shortlinkmapper.ShortLinkReqDTO;

import java.util.List;
import java.util.Map;

/**
 * 短链接接口层
 *
 * @author wp
 */
public interface ShortLinkService extends IService<ShortLinkDO> {
    /**
     * 分组获取短链接
     */
    List<ShortLinkReqDTO> queryShortLinkByGid(Long gid);

    /**
     * 分页查询短链接
     */
    IPage<ShortLinkVO> pageGroup(ShortLinkGroupPageReqDTO shortLinkPage);

    /**
     * 分页查询
     */
    IPage<ShortLinkVO> queryPage(Page<ShortLinkDO> page, QueryWrapper<ShortLinkDO> queryWrapper, String orderTag, Boolean desc);

    /**
     * 创建短链接
     */
    void createShortLink(ShortLinkCreateReqDTO requestParam);

    /**
     * 批量创建短链接
     */
    void batchCreateShortLink(ShortLinkBatchCreateReqDTO requestParam);

    /**
     * 修改短链接
     */
    void updateShortLink(ShortLinkUpdateReqDTO shortLinkUpdate);

    /**
     * 移入回收站
     */
    void moveToRecycleBin(Long id);

    /**
     * 查询短链接分组内数量
     */
    Map<Long, Integer> listGroupShortLinkCount(List<Long> groupIds);

    /**
     * 根据短链获取原链
     */
    String getOriginByShortLink(String domain, String shortLink);
}